package com.ambimmort.shj.service.device;

import cn.net.greenet.device.ud.UddeviceManageService;
import net.sf.json.JSONArray;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by zyt on 2015/7/31.
 */
@Service
public class UdDeviceService {
    @Autowired
    private SessionFactory hibernateSessionFactory;

    public boolean updateTddeviceDevice(String ip, String port, String desc) {
        boolean flag = false;

            /* TODO output your page here. You may use following sample code. */
        UddeviceManageService udd = new UddeviceManageService();
        flag = udd.insert(ip, port, "0", desc, null, null, null, null);
        return flag;
    }

    public boolean delUddeviceDevice(String ip, String port) {
        boolean flag = false;
            /* TODO output your page here. You may use following sample code. */
        UddeviceManageService udd = new UddeviceManageService();
        flag = udd.delete(ip, port);
        return flag;
    }

    public String queryUddeviceDevice() {
        UddeviceManageService udd = new UddeviceManageService();
        JSONArray arr = udd.findAll();
        return arr.toString();
    }

    /**
     *
     */
    public boolean updateUddeviceDevice(String old_ip, String old_port, String ip, String port, String isRun, String desc) {
        boolean flag = false;
            /* TODO output your page here. You may use following sample code. */
        UddeviceManageService udd = new UddeviceManageService();
        flag = udd.update(old_ip, old_port, ip, port, isRun, desc, null, null, null, null);
        return flag;
    }
}
